import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      name: 'Layout',
      path: '/',
      redirect: '/all',
      component: () => import('@/components/Layout'),
      children: [
        {
          name: 'All',
          path: '/all',
          component: () => import('@/views/article/All')
        },
        {
          name: '热门文章',
          path: '/hot',
          component: () => import('@/views/article/Common')
        },
        {
          name: 'HTML/CSS',
          path: '/html',
          component: () => import('@/views/article/Common')
        },
        {
          name: 'JavaScript',
          path: '/javaScript',
          component: () => import('@/views/article/Common')
        },
        {
          name: 'PHP',
          path: '/php',
          component: () => import('@/views/article/Common')
        },
        {
          name: 'Go',
          path: '/go',
          component: () => import('@/views/article/Common')
        },
        {
          name: 'Python',
          path: '/python',
          component: () => import('@/views/article/Common')
        },
        {
          name: 'Java',
          path: '/java',
          component: () => import('@/views/article/Common')
        }
      ]
    },
    {
      name: 'WriteArticle',
      path: '/writeArticle',
      component: () => import('@/views/article/WriteArticle')
    },
    {
      name: 'jobCertification',
      path: '/jobCertification',
      component: () => import('@/views/article/Job')
    },
    {
      name: 'Login',
      path: '/login',
      component: () => import('@/views/article/LoginAndRegist')
    },
    {
      name: 'Regist',
      path: '/regist',
      component: () => import('@/views/article/LoginAndRegist')
    },
    {
      name: 'ArticleContent',
      path: '/articleContent',
      component: () => import('@/views/article/Content')
    },
    {
      name: 'ArticleDetails',
      path: '/articleDetails',
      component: () => import('@/views/article/Details')
    },
    {
      name: 'ArticleOrder',
      path: '/articleOrder',
      component: () => import('@/views/article/Order')
    },
    {
      name: 'Article',
      path: '/article',
      component: () => import('@/views/article/Article')
    },
    {
      name: 'User',
      path: '/user',
      redirect: '/myInfo',
      component: () => import('@/views/article/User'),
      children: [
        {
          name: 'MyInfo',
          path: '/myInfo',
          component: () => import('@/views/article/MyInfo')
        },
        {
          name: 'MyCollection',
          path: '/myCollection',
          component: () => import('@/views/article/MyCollection')
        },
        {
          name: 'MyFollowee',
          path: '/myFollowee',
          component: () => import('@/views/article/MyFollowee')
        },
        {
          name: 'MyFans',
          path: '/myFans',
          component: () => import('@/views/article/MyFans')
        },
        {
          name: 'MyArticle',
          path: '/myArticle',
          component: () => import('@/views/article/MyArticle')
        },
        {
          name: 'PutOutArticle',
          path: '/putOutArticle',
          component: () => import('@/views/article/PutOutArticle')
        },
        {
          name: 'MyWallet',
          path: '/myWallet',
          component: () => import('@/views/article/MyWallet')
        },
        {
          name: 'MyOrder',
          path: '/myOrder',
          component: () => import('@/views/article/MyOrder')
        }
      ]
    },
    {
      name: 'AccountSettings',
      path: '/accountSettings',
      redirect: '/accountSettingsIndex',
      component: () => import('@/views/article/AccountSettings'),
      children: [
        {
          name: 'AccountSettingsIndex',
          path: '/accountSettingsIndex',
          component: () => import('@/views/article/AccountSettingsIndex')
        },
        {
          name: 'UpdatePassword',
          path: '/updatePassword',
          component: () => import('@/views/article/UpdatePassword')
        },
        {
          name: 'UpdatePhone',
          path: '/updatePhone',
          redirect: '/updatePhoneStep1',
          component: () => import('@/views/article/UpdatePhone'),
          children: [
            {
              name: 'UpdatePhoneStep1',
              path: '/updatePhoneStep1',
              component: () => import('@/views/article/UpdatePhoneStep1')
            },
            {
              name: 'UpdatePhoneStep2',
              path: '/updatePhoneStep2',
              component: () => import('@/views/article/UpdatePhoneStep2')
            },
            {
              name: 'UpdatePasswordStep3',
              path: '/updatePhoneStep3',
              component: () => import('@/views/article/UpdatePhoneStep3')
            }
          ]
        },
        {
          name: 'updateEmail',
          path: '/updateEmail',
          component: () => import('@/views/article/UpdateEmail')
        },
        {
          name: 'BindLoginMethod',
          path: '/bindLoginMethod',
          component: () => import('@/views/article/BindLoginMethod')
        }
      ]
    },
    {
      name: 'Advise',
      path: '/advise',
      redirect: '/commonAdvise',
      component: () => import('@/views/article/Advise'),
      children: [
        {
          name: 'CommonAdvise',
          path: '/commonAdvise',
          component: () => import('@/views/article/CommonAdvise')
        },
        {
          name: 'CommentAdvise',
          path: '/commentAdvise',
          component: () => import('@/views/article/CommentAdvise')
        },
        {
          name: 'FolloweeAdvise',
          path: '/followeeAdvise',
          component: () => import('@/views/article/FolloweeAdvise')
        },
        {
          name: 'PersonalAdvise',
          path: '/personalAdvise',
          component: () => import('@/views/article/PersonalAdvise')
        },
        {
          name: '/SystemAdvise',
          path: '/systemAdvise',
          component: () => import('@/views/article/SystemAdvise')
        },
        {
          name: 'AdviseSettings',
          path: '/adviseSettings',
          component: () => import('@/views/article/AdviseSettings')
        }
      ]
    }
  ]
})
